package com.yuanfeng.goods.controller;

import com.yuanfeng.commoms.dto.goods.ShopListQueryDTO;
import com.yuanfeng.commoms.dto.goods.WebGoodsListQueryDTO;
import com.yuanfeng.commoms.dto.shop.WebShopListQueryDTO;
import com.yuanfeng.commoms.util.ResponseResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/es")
public class ElasticSearchController extends BaseController {


    /**
     * 创建商品索引库
     */
    @RequestMapping("/createGoodsIndex")
    public ResponseResult createGoodsIndex() {
        ResponseResult goodsIndex = elasticSearchService.createGoodsIndex();
        return goodsIndex;
    }

    /**
     * 创建店铺索引库
     */
    @RequestMapping("/createShopIndex")
    public ResponseResult createShopIndex() {
        ResponseResult shopIndex = elasticSearchService.createShopIndex();
        return shopIndex;
    }

    /**
     * 删除商品索引库
     */
    @RequestMapping("/deleteGoodsIndex")
    public ResponseResult deleteGoodsIndex() {
        ResponseResult result = elasticSearchService.deleteGoodsIndex();
        return result;
    }

    /**
     * 删除店铺索引库
     */
    @RequestMapping("/deleteShopIndex")
    public ResponseResult deleteShopIndex() {
        ResponseResult result = elasticSearchService.deleteShopIndex();
        return result; 
    }

    /**
     * 导入商品数据
     */
    @RequestMapping("/importGoodsData")
    public ResponseResult importData() {
        ResponseResult result = elasticSearchService.importData();
        return result;
    }

    /**
     * 导入店铺信息
     */
    @RequestMapping("/importShopData")
    public ResponseResult importShopData() {
        ResponseResult result = elasticSearchService.importShopData();
        return result;
    }

    /**
     * 删除所有商品数据
     */
    @RequestMapping("/deleteGoodsData")
    public ResponseResult deleteGoodsData() {
        ResponseResult result = elasticSearchService.deleteGoodsData();
        return result;
    }

    /**
     * 删除所有店铺数据
     */
    @RequestMapping("/deleteShopData")
    public ResponseResult deleteShopData() {
        ResponseResult result = elasticSearchService.deleteShopData();
        return result;
    }

    /**
     * pc的商品搜索 查询品牌 商品属性等
     * @param webGoodsListQueryParam
     * @return
     * @throws Exception
     */
    @RequestMapping("/querySeachBrandAttributeData")
    public ResponseResult querySeachBrandAttributeData(@RequestBody WebGoodsListQueryDTO webGoodsListQueryParam) {
        ResponseResult result = elasticSearchService.querySeachBrandAttributeData(webGoodsListQueryParam);
        return result;
    }

    /**
     * pc的商品搜索
     *
     * @param webGoodsListQueryParam
     * @return
     * @throws Exception
     */
    @RequestMapping("/pcSeachGoodsData")
    public ResponseResult pcSeachGoodsData(@RequestBody WebGoodsListQueryDTO webGoodsListQueryParam) {
        ResponseResult result = elasticSearchService.pcSeachGoodsData(webGoodsListQueryParam);
        return result;
    }

    /**
     * pc的店铺搜索
     *
     * @param webGoodsListQueryParam
     * @return
     * @throws Exception
     */
    @RequestMapping("/pcSeachShopData")
    public ResponseResult pcSeachShopData(@RequestBody WebShopListQueryDTO webGoodsListQueryParam) {
        ResponseResult result = elasticSearchService.pcSeachShopData(webGoodsListQueryParam);
        return result;
    }

    /**
     * h5的商品搜索
     *
     * @param webGoodsListQueryParam
     * @return
     * @throws Exception
     */
    @RequestMapping("/h5SeachGoodsData")
    public ResponseResult h5SeachGoodsData(@RequestBody WebGoodsListQueryDTO webGoodsListQueryParam) {
        ResponseResult result = elasticSearchService.h5SeachGoodsData(webGoodsListQueryParam);
        return result;
    }

    /**
     * h5的店铺搜索
     *
     * @param shopListQueryParam
     * @return
     * @throws Exception
     */
    @RequestMapping("/h5SeachShopData")
    public ResponseResult h5SeachShopData(@RequestBody ShopListQueryDTO shopListQueryParam) {
        ResponseResult result = elasticSearchService.h5SeachShopData(shopListQueryParam);
        return result;
    }

}
